//
//  Resource.hpp
//  myhttpserver
//
//  Created by tgy on 2018/3/21.
//  Copyright © 2018年 tgy. All rights reserved.
//

#ifndef Resource_hpp
#define Resource_hpp

#include <stdio.h>
#include <string>
class Resource {
    
private:
    char *data;
    int len;
    std::string localPath;
    int mineType;
public:
    Resource(){
        data = NULL;
        len = 0;
    }
    Resource( char *data,  int len){
        this->data = data;
        if (len < 0) {
            
            len = 0;
        }
        this->len = len;
    }
    
    Resource( char *data,  int len,std::string localPath){
        
        this->data = data;
        if (len < 0 ) {
            
            len = 0;
        }
        this->len = len;
        this->localPath = localPath;
    }
    
    ~Resource(){
        
        if (this->data != NULL) {
            
            delete [] this->data;
        }
    }
    
    void setData(char *data){
        
        this->data = data;
    }
    
    char *getData(){
        
        return this->data;
    }
    int getLen(){
        
        return len;
    }
    
    void setLen(int len){
        
        if (len > 0) {
            
            this->len = len;
        }
    }
    
    void setLocalPath(std::string localPath){
        
        this->localPath = localPath;
    }
    std::string getLocalPath(){
        
        return this->localPath;
    }
    
    void setMineType(int mineType){
        
        this->mineType = mineType;
    }
    
    int getMineType(){
        
        return this->mineType;
    }
};

#endif /* Resource_hpp */
